/*
 * author: tim;
 * date:9.16
 */
#ifndef BANK_H
#define BANK_H

class Bank//接口， 抽象工厂模式
{
    protected:
        int balance;

    public:
        Bank(): balance(0) {};
        Bank(int amount): balance(amount) {};
        void change(int chg) {balance = chg;}
        friend int total(Bank&, Bank&, Bank&);
        friend void show_in_terminal2(Bank&, Bank&, Bank&);
        ~Bank() {};
};
//具体实现， 实例模式, 同时向上造型， upcasting
class CBank: public Bank
{
    public: CBank(): Bank() {}; CBank(int amount): Bank(amount) {};
};
class BBank: public Bank
{
    public: BBank(): Bank() {}; BBank(int amount): Bank(amount) {};
};
class GBank: public Bank
{
    public: GBank(): Bank() {}; GBank(int amount): Bank(amount) {};
};

int total(Bank& a, Bank& b, Bank& c)
{
    return a.balance + b.balance + c.balance;
}
void show_in_terminal2(Bank& a, Bank& b, Bank& c)
{
    std::cout<<"-----------------------\n"
             <<"a is: "<<a.balance<<", b is: "<<b.balance<<", c is: "<<c.balance<<" ,\n"
             <<"total is: "<< total(a, b, c)<<" .\n"
             <<"-----------------------\n";
}

#endif

